<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>node_blog</title>
    <link rel="stylesheet" href="/frame/layui/css/layui.css">
    <style>
        body{
            padding-bottom: 100px;
        }
        .layui-card-body{
            padding-top: 30px;
        }
    </style>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title">
    <legend>密码修改</legend>
</fieldset>
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" >
            <div class="layui-form-item">
                <label class="layui-form-label">旧密码</label>
                <div class="layui-input-block">
                    <input type="password" name="oldpassword" required lay-verify="required" placeholder="请输入旧密码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-block">
                    <input type="password" name="newpassword" required lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-block">
                    <input type="password" name="repassword" required lay-verify="required" placeholder="请再次输入新密码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                    <button type="button" class="layui-btn layui-btn-danger" lay-submit lay-filter="repassword">立即修改</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="/frame/layui/layui.js"></script>
<script>
    //JavaScript代码区域
    layui.use(['element','jquery','form'], function(){
        let element = layui.element;
        let $ = layui.jquery;
        let form=layui.form;
        //控制显示宽高
        let iframe= window.parent.document.getElementById('iframe');
        iframe.style.height=document.body.clientHeight +'px';

     form.on('submit(repassword)',function (data) {
           $.ajax({
               type:'post',
               dataType:'json',
               data:data.field,
               url:'/repassword/pwdreset',
               success:function (result) {
                    if(result==='密码修改成功，请重新登录!'){
                        layer.msg(result,{
                            icon:6
                        })
                        setTimeout(function () {
                            top.location.href='../signin'
                        },1000)
                    }else {
                        layer.msg(result,{
                            icon:5
                        })
                        setTimeout(function () {
                            window.location.reload();
                        },1000)
                    }
               },
               error:function (msg) {
                   layer.msg(msg,{
                       icon:5
                   });
               }
           })
     })
    });
</script>
</body>
</html>